/*
 * @Author: Mr.Mao
 * @Date: 2021-05-16 14:59:57
 * @LastEditTime: 2021-06-24 01:22:00
 * @Description: 
 * @LastEditors: Mr.Mao
 * @autograph: 任何一个傻子都能写出让电脑能懂的代码，而只有好的程序员可以写出让人能看懂的代码
 */
import { createModel } from './connect'
import { TUserInfo } from './types'
/** 用户表 */
export const UserModel = createModel({
  // 用户头像
  avatar: { type: String, maxlength: 250, default: 'https://c-ssl.duitang.com/uploads/item/202003/06/20200306161737_nvvdp.jpeg' },
  // 用户名
  account: { type: String, minlength: 3, maxlength: 15 },
  // 昵称
  nickName: { type: String, minlength: 3, maxlength: 15 },
  // 密码
  password: { type: String },
  // 手机号码
  phone: { type: String },
  // 邮箱
  mail: { type: String },
  // 性别
  gender: { type: String, match: /^women|men|secrecy$/, default: 'secrecy' },
  // 创建时间
  createTime: { type: Date, default: Date.now },
  // 最后登录时间
  lastLoginTime: { type: Date }
})('user')

/** 联系人表 */
export const ContactModel = createModel({
  uid: [{ type: [String, Number], required: true }],
  fid: { type: String, required: true },
  createTime: { type: Date, default: Date.now }
})('contact')

;(async () => {
  const user = await ContactModel.findOne()
  user.uid
  user.fid
  user.createTime
})
/** 群表 */
export const GroupModel = createModel({
  
})